// shared.cpp: Source file for shared code.
// Written by Victor Luna Freire - victorclf@live.com
// Copyright (c) Victor Luna Freire. All rights reserved.
// Wednesday, October 28, 2009 3:56:48 PM

#include "shared.h"


// Operators for Vec2i
bool operator==(const Vec2i& lhs, const Vec2i& rhs) 
{ 
	return lhs.x == rhs.x && lhs.y == rhs.y; 
};

bool operator!=(const Vec2i& lhs, const Vec2i& rhs) 
{ 
	return !(lhs == rhs);
};


// Simple random function. Interval: [min, max)
namespace {
	bool rand_init;
}
int random(int max) // [0, max)
{ 
	return random(0, max);
}
int random(int min, int max) // [min, max)
{
	if(!rand_init) {
		srand(int(time(0)));
		rand_init = true;
	}
	return (rand() % (max - min)) + min; //the % does not generate a truly uniformly distributed random number
}

